Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.

fix: enable defs references in tool calls#3291

Open
drbh wants to merge 2 commits intomainfrom
fix-tool-call-def
Open

fix: enable defs references in tool calls#3291
drbh wants to merge 2 commits intomainfrom
fix-tool-call-def

Conversation

@drbh
Copy link
Copy Markdown
Collaborator

@drbh drbh commented Jul 7, 2025

This PR enables $defs to be set inside of function parameters

example:

import requests
import json

url = "http://localhost:3000/v1/chat/completions"

payload = {
    "messages": [
        {
            "content": "Classify the weather: It's sunny outside with clear skies",
            "role": "user",
        }
    ],
    "model": "test-model",
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "classify_weather",
                "description": "Classify weather conditions",
                "parameters": {
                    "$defs": {
                        "WeatherType": {
                            "enum": ["sunny", "cloudy", "rainy", "snowy"],
                            "type": "string",
                        }
                    },
                    "properties": {"weather": {"$ref": "#/$defs/WeatherType"}},
                    "required": ["weather"],
                    "type": "object",
                },
            },
        }
    ],
}

response = requests.post(url, json=payload)

print(json.dumps(response.json(), indent=2))

expected response

{
  "object": "chat.completion",
  "id": "",
  "created": 1751895703,
  "model": "test-model",
  "system_fingerprint": "3.3.4-dev0-native",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "tool_calls": [
          {
            "id": "0",
            "type": "function",
            "function": {
              "description": null,
              "name": "classify_weather",
              "arguments": "{\"weather\":\"sunny\"}"
            }
          }
        ]
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 196,
    "completion_tokens": 18,
    "total_tokens": 214
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant